package top.v5it.japi.plus.core.exception.handler;


import top.v5it.japi.plus.core.api.ErrorResult;
import top.v5it.japi.plus.core.api.ResultStatus;

import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

/**
 * 一个简单的统一错误异常处理类
 *
 * @author zhanpu
 */
public class SimpleJapiResponseExceptionHandler implements JapiResponseExceptionSet {

    @Override
    public Set<Class<?>> getExceptionSet() {
        return Collections.emptySet();
    }

    /**
     * 统一错误异常处理
     *
     * @param response {@link HttpServletResponse}
     * @param ex       具体异常类
     * @return {@link Map <String, Object>}
     * @throws Exception 方法本身也可能抛出异常
     */
    public ErrorResult resolveException(HttpServletResponse response, Exception ex) throws Exception {

        return createReturnError(response, ResultStatus.SYSTEM_ERROR);
    }
}
